home *** CD-ROM | disk | FTP | other *** search
- Path: news.lpr.carel.fi!usenet
- From: Ari Lukumies <aril@cmt.lpr.mail.carel.fi>
- Newsgroups: comp.lang.c
- Subject: Re: How to tell if a file exists in C
- Date: Thu, 08 Feb 1996 16:31:43 +0200
- Organization: Carelcomp Forest
- Message-ID: <311A094F.6F12@cmt.lpr.mail.carel.fi>
- References: <823685019.AA00170@escan.demon.co.uk>
- NNTP-Posting-Host: renoir.cclahti.carel.fi
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0b6a (WinNT; I)
-
- Bill Birrell wrote:
- >
- > > Hi, how do I find out if a file already exists
- > > in UNIX C? On PCs I would do a findfirst/findnext,
- > > is there an equivalent on Unix?
- >
- > Check up on access() and stat(). There cannot be an exact equivalent to
- > Digital Research's findfirst and findnext functions in unix, because unix has
- > a completely different file structure from CP/M or PC-Dos (later MsDos), and
- > therefore has no idea what FCBs are. Files, directories and devices are all
- > accessed the same way, and when you become used to it, it is a *much* simpler
- > and more logical approach. Take a look at K&R Chapter 8 [Either edition - it's
- > in both].
- >
-
- If you know the name of the file the existance of which you want to check, try
-
- remove(filename);
-
- If it succeeded, the file did exist. :)
-
- Later,
- AriL
- --
- All my opinions are mine and mine alone.
-